﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ZGEDrySaltery.Web.s_user
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtORG_ID.Text))
			{
				strErr+="ORG_ID格式错误！\\n";	
			}
			if(this.txtUSER_NAME.Text.Trim().Length==0)
			{
				strErr+="USER_NAME不能为空！\\n";	
			}
			if(this.txtREAL_NAME.Text.Trim().Length==0)
			{
				strErr+="REAL_NAME不能为空！\\n";	
			}
			if(this.txtSEX.Text.Trim().Length==0)
			{
				strErr+="SEX不能为空！\\n";	
			}
			if(this.txtID_CARD.Text.Trim().Length==0)
			{
				strErr+="ID_CARD不能为空！\\n";	
			}
			if(this.txtUSER_PSD.Text.Trim().Length==0)
			{
				strErr+="USER_PSD不能为空！\\n";	
			}
			if(this.txtOPEN_ID.Text.Trim().Length==0)
			{
				strErr+="OPEN_ID不能为空！\\n";	
			}
			if(this.txtTEL.Text.Trim().Length==0)
			{
				strErr+="TEL不能为空！\\n";	
			}
			if(this.txtEMAIL.Text.Trim().Length==0)
			{
				strErr+="EMAIL不能为空！\\n";	
			}
			if(this.txtIMAGE_PATH.Text.Trim().Length==0)
			{
				strErr+="IMAGE_PATH不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtLAST_ONLINE_TIME.Text))
			{
				strErr+="on update CURRE格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtLOGIN_TIMES.Text))
			{
				strErr+="LOGIN_TIMES格式错误！\\n";	
			}
			if(this.txtENABLE_FLAG.Text.Trim().Length==0)
			{
				strErr+="ENABLE_FLAG不能为空！\\n";	
			}
			if(this.txtCREATE_USER_ID.Text.Trim().Length==0)
			{
				strErr+="CREATE_USER_ID不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCREATE_TIME.Text))
			{
				strErr+="on update CURRE格式错误！\\n";	
			}
			if(this.txtUPDATE_USER_ID.Text.Trim().Length==0)
			{
				strErr+="UPDATE_USER_ID不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUPDATE_TIME.Text))
			{
				strErr+="on update CURRE格式错误！\\n";	
			}
			if(this.txtREMARK.Text.Trim().Length==0)
			{
				strErr+="REMARK不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtTENANT_ID.Text))
			{
				strErr+="TENANT_ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int ORG_ID=int.Parse(this.txtORG_ID.Text);
			string USER_NAME=this.txtUSER_NAME.Text;
			string REAL_NAME=this.txtREAL_NAME.Text;
			string SEX=this.txtSEX.Text;
			string ID_CARD=this.txtID_CARD.Text;
			string USER_PSD=this.txtUSER_PSD.Text;
			string OPEN_ID=this.txtOPEN_ID.Text;
			string TEL=this.txtTEL.Text;
			string EMAIL=this.txtEMAIL.Text;
			string IMAGE_PATH=this.txtIMAGE_PATH.Text;
			DateTime LAST_ONLINE_TIME=DateTime.Parse(this.txtLAST_ONLINE_TIME.Text);
			int LOGIN_TIMES=int.Parse(this.txtLOGIN_TIMES.Text);
			string ENABLE_FLAG=this.txtENABLE_FLAG.Text;
			string CREATE_USER_ID=this.txtCREATE_USER_ID.Text;
			DateTime CREATE_TIME=DateTime.Parse(this.txtCREATE_TIME.Text);
			string UPDATE_USER_ID=this.txtUPDATE_USER_ID.Text;
			DateTime UPDATE_TIME=DateTime.Parse(this.txtUPDATE_TIME.Text);
			string REMARK=this.txtREMARK.Text;
			int TENANT_ID=int.Parse(this.txtTENANT_ID.Text);

			ZGEDrySaltery.Model.s_user model=new ZGEDrySaltery.Model.s_user();
			model.ORG_ID=ORG_ID;
			model.USER_NAME=USER_NAME;
			model.REAL_NAME=REAL_NAME;
			model.SEX=SEX;
			model.ID_CARD=ID_CARD;
			model.USER_PSD=USER_PSD;
			model.OPEN_ID=OPEN_ID;
			model.TEL=TEL;
			model.EMAIL=EMAIL;
			model.IMAGE_PATH=IMAGE_PATH;
			model.LAST_ONLINE_TIME=LAST_ONLINE_TIME;
			model.LOGIN_TIMES=LOGIN_TIMES;
			model.ENABLE_FLAG=ENABLE_FLAG;
			model.CREATE_USER_ID=CREATE_USER_ID;
			model.CREATE_TIME=CREATE_TIME;
			model.UPDATE_USER_ID=UPDATE_USER_ID;
			model.UPDATE_TIME=UPDATE_TIME;
			model.REMARK=REMARK;
			model.TENANT_ID=TENANT_ID;

			ZGEDrySaltery.BLL.s_user bll=new ZGEDrySaltery.BLL.s_user();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
